[IA64] Use virtualized psr in vcpu context instead of real psr.
authorAlex Williamson <alex.williamson@hp.com>
Tue, 12 Jun 2007 21:16:03 +0000 (15:16 -0600)
committerAlex Williamson <alex.williamson@hp.com>
Tue, 12 Jun 2007 21:16:03 +0000 (15:16 -0600)
Signed-off-by: Tristan Gingold <tgingold@free.fr>
tools/libxc/ia64/xc_ia64_hvm_build.c
tools/libxc/ia64/xc_ia64_linux_restore.c
tools/libxc/xc_dom_ia64.c
xen/arch/ia64/vmx/vlsapic.c
xen/arch/ia64/xen/domain.c
xen/arch/ia64/xen/hypercall.c
xen/arch/ia64/xen/vcpu.c

index 690d12c8f964f3724af6fcc0c0d061b42d6534a5..0c0a9e36e0095e4cb46725a99044ec3f3a9b6a81 100644 (file)
@@ -1,3 +1,4 @@
+#include <asm/kregs.h>
 #include "xg_private.h"
 #include "xenguest.h"
 #include "xc_private.h"
@@ -1083,6 +1084,11 @@ xc_hvm_build(int xc_handle, uint32_t domid, int memsize, const char *image_name)
     free(image);
 
     ctxt->regs.ip = 0x80000000ffffffb0UL;
+    ctxt->regs.ar.fpsr = xc_ia64_fpsr_default();
+    ctxt->regs.cr.isr = 1UL << 63;
+    ctxt->regs.psr = IA64_PSR_AC | IA64_PSR_BN;
+    ctxt->regs.cr.dcr = 0;
+    ctxt->regs.cr.pta = 15 << 2;
 
     memset(&launch_domctl, 0, sizeof(launch_domctl));
 
index 509533904cc142c07be5fb6c71416e2a024cde47..26a39715c0f7143d10e7bd3028667c5ebce1dba3 100644 (file)
@@ -227,17 +227,7 @@ xc_domain_restore(int xc_handle, int io_fd, uint32_t dom,
 
     fprintf(stderr, "ip=%016lx, b0=%016lx\n", ctxt.regs.ip, ctxt.regs.b[0]);
 
-    /* First to initialize.  */
-    domctl.cmd = XEN_DOMCTL_setvcpucontext;
-    domctl.domain = (domid_t)dom;
-    domctl.u.vcpucontext.vcpu   = 0;
-    set_xen_guest_handle(domctl.u.vcpucontext.ctxt, &ctxt);
-    if (xc_domctl(xc_handle, &domctl) != 0) {
-        ERROR("Couldn't set vcpu context");
-        goto out;
-    }
-
-    /* Second to set registers...  */
+    /* Initialize and set registers.  */
     ctxt.flags = VGCF_EXTRA_REGS;
     domctl.cmd = XEN_DOMCTL_setvcpucontext;
     domctl.domain = (domid_t)dom;
index 18b129fc112fd1ba7d659d3f703cb7c466bc8c65..7c7eac0eb26ef5a3d63c1d861ef8146a6555b315 100644 (file)
@@ -13,6 +13,7 @@
 #include <string.h>
 #include <inttypes.h>
 #include <assert.h>
+#include <asm/kregs.h>
 
 #include <xen/xen.h>
 #include <xen/foreign/ia64.h>
@@ -106,9 +107,10 @@ static int vcpu_ia64(struct xc_dom_image *dom, void *ptr)
     memset(ctxt, 0, sizeof(*ctxt));
 
     ctxt->flags = 0;
-    ctxt->regs.psr = 0;        /* all necessary bits filled by hypervisor */
+    /* PSR is set according to SAL 3.2.4: AC, IC and BN are set. */
+    ctxt->regs.psr = IA64_PSR_AC | IA64_PSR_IC | IA64_PSR_BN;
     ctxt->regs.ip = dom->parms.virt_entry;
-    ctxt->regs.cfm = (uint64_t) 1 << 63;
+    ctxt->regs.cfm = 1UL << 63;
 #ifdef __ia64__                        /* FIXME */
     ctxt->regs.ar.fpsr = xc_ia64_fpsr_default();
 #endif
index b262a809c496b8cac805d6a066e9bf976eccb561..10e42a7f7546cef940311d1da2f89749c8ad1182 100644 (file)
@@ -696,11 +696,8 @@ static void vlsapic_write_ipi(VCPU *vcpu, uint64_t addr, uint64_t value)
         test_bit(_VPF_down, &targ->pause_flags)) {
 
         struct pt_regs *targ_regs = vcpu_regs(targ);
-        struct vcpu_guest_context c;
 
-        memset (&c, 0, sizeof(c));
-
-        if (arch_set_info_guest(targ, &c) != 0) {
+        if (arch_set_info_guest(targ, NULL) != 0) {
             printk("arch_boot_vcpu: failure\n");
             return;
         }
index b9b86adc447fb46faf84a8bb067f3dc708c6f456..1661e279afbd1777af622cf2dfe64dda7bd68f19 100644 (file)
@@ -622,12 +622,10 @@ void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c)
        c.nat->regs.r[10] = uregs->r10;
        c.nat->regs.r[11] = uregs->r11;
 
-       if (is_hvm) {
-               c.nat->regs.psr = vmx_vcpu_get_psr (v);
-       } else {
-               /* FIXME: get the vpsr.  */
-               c.nat->regs.psr = uregs->cr_ipsr;
-       }
+       if (is_hvm)
+               c.nat->regs.psr = vmx_vcpu_get_psr(v);
+       else
+               c.nat->regs.psr = vcpu_get_psr(v);
 
        c.nat->regs.ip = uregs->cr_iip;
        c.nat->regs.cfm = uregs->cr_ifs;
@@ -717,6 +715,26 @@ int arch_set_info_guest(struct vcpu *v, vcpu_guest_context_u c)
        struct domain *d = v->domain;
        int rc;
 
+       /* Finish vcpu initialization.  */
+       if (!v->is_initialised) {
+               if (d->arch.is_vti)
+                       rc = vmx_final_setup_guest(v);
+               else
+                       rc = vcpu_late_initialise(v);
+               if (rc != 0)
+                       return rc;
+
+               vcpu_init_regs(v);
+
+               v->is_initialised = 1;
+               /* Auto-online VCPU0 when it is initialised. */
+               if (v->vcpu_id == 0)
+                       clear_bit(_VPF_down, &v->pause_flags);
+       }
+
+       if (c.nat == NULL)
+               return 0;
+
        uregs->b6 = c.nat->regs.b[6];
        uregs->b7 = c.nat->regs.b[7];
        
@@ -727,8 +745,11 @@ int arch_set_info_guest(struct vcpu *v, vcpu_guest_context_u c)
        uregs->r9 = c.nat->regs.r[9];
        uregs->r10 = c.nat->regs.r[10];
        uregs->r11 = c.nat->regs.r[11];
-       
-       uregs->cr_ipsr = c.nat->regs.psr;
+
+       if (!d->arch.is_vti)
+               vcpu_set_psr(v, c.nat->regs.psr);
+       else
+               vmx_vcpu_set_psr(v, c.nat->regs.psr);
        uregs->cr_iip = c.nat->regs.ip;
        uregs->cr_ifs = c.nat->regs.cfm;
        
@@ -813,32 +834,6 @@ int arch_set_info_guest(struct vcpu *v, vcpu_guest_context_u c)
                v->arch.iva = c.nat->regs.cr.iva;
        }
 
-       if (v->is_initialised)
-               return 0;
-
-       if (d->arch.is_vti) {
-               rc = vmx_final_setup_guest(v);
-               if (rc != 0)
-                       return rc;
-       } else {
-               rc = vcpu_late_initialise(v);
-               if (rc != 0)
-                       return rc;
-               VCPU(v, interrupt_mask_addr) = 
-                       (unsigned char *) d->arch.shared_info_va +
-                       INT_ENABLE_OFFSET(v);
-       }
-
-       /* This overrides some registers. */
-       vcpu_init_regs(v);
-
-       if (!v->is_initialised) {
-               v->is_initialised = 1;
-               /* Auto-online VCPU0 when it is initialised. */
-               if (v->vcpu_id == 0)
-                       clear_bit(_VPF_down, &v->pause_flags);
-       }
-
        return 0;
 }
 
index e43a9ed5e9a898e923dcdf3dc8c4acc4aaaf4b67..dffc95e5f6a56ad4df0ab545fc81603f83b0bfc5 100644 (file)
@@ -86,11 +86,7 @@ fw_hypercall_ipi (struct pt_regs *regs)
 
                /* First start: initialize vpcu.  */
                if (!targ->is_initialised) {
-                       struct vcpu_guest_context c;
-               
-                       memset (&c, 0, sizeof (c));
-
-                       if (arch_set_info_guest (targ, &c) != 0) {
+                       if (arch_set_info_guest (targ, NULL) != 0) {
                                printk ("arch_boot_vcpu: failure\n");
                                return;
                        }
index 4a6227515f461cf7e6e0786e9acca7d39f935ee0..120072d4b8c2434a7dbd4d3800d56137e9800dde 100644 (file)
@@ -182,8 +182,6 @@ void vcpu_init_regs(struct vcpu *v)
                    INT_ENABLE_OFFSET(v);
                VCPU(v, itv) = (1 << 16);       /* timer vector masked */
 
-               /* SAL specification 3.2.4 */
-               VCPU(v, vpsr) = IA64_PSR_AC | IA64_PSR_IC | IA64_PSR_BN;
                v->vcpu_info->evtchn_upcall_pending = 0;
                v->vcpu_info->evtchn_upcall_mask = -1;
        }